// this clicks on the link after page is loaded, // there is whole process going before coming to this point. await page.click('#ctl00_chpMain_ucContractDetails'); const url = await newPage.evaluate(() => document.location.href); console.log(url); // this code didnt work for me.Necesita capturar el evento de creación de pestañas:
const [url] = await Promise.all([ new Promise((resolve, reject) => { browser.once('targetcreated', (target) => { resolve(target.url()); }); }), page.click('#ctl00_chpMain_ucContractDetails'), ]); console.log(url);